home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’93 / Mystery Science Mac / INIT sources / Utils.h < prev   
C/C++ Source or Header  |  1993-09-01  |  4KB  |  145 lines

  1. #pragma once
  2.  
  3. typedef unsigned char  uchar;
  4. typedef unsigned short ushort;
  5. typedef unsigned long  ulong;
  6.  
  7. extern struct Keyboard {
  8.     short    wasted;
  9.     short    wasted2;
  10.     short    wasted3;
  11.     int command : 1;
  12.     int : 5;
  13.     int space : 1;
  14.     int tab : 1;
  15.     int : 4;
  16.     int control : 1;
  17.     int option : 1;
  18.     int capslock : 1;
  19.     int shift : 1;
  20. } keymap : 0x174;
  21.  
  22.     // this structure is useful for interpreting the fdFlags field of the FInfo structure.
  23. typedef struct {
  24.     int isAlias        : 1;
  25.     int isInvisible : 1;
  26.     int hasBundle    : 1;
  27.     int nameLocked    : 1;
  28.     int isStationery: 1;
  29.     int hasCustomIcn: 1;
  30.     int             : 1;
  31.     int wasInited    : 1;
  32.     int hasNoINITS    : 1;
  33.     int isShared    : 1;
  34.     int SwitchLaunch: 1;
  35.     int             : 1;
  36.     int color       : 3;
  37.     int             : 1;
  38. } FileFlags;
  39.  
  40. // SetA4 is an inline for setting register a4 without using inline assembly.
  41. // it returns the old value of a4.
  42.  
  43. #pragma parameter __A0 SetA4(__A0)
  44. pascal void *SetA4(void *newA4) = 0xC948;
  45.  
  46. // CopyHandle is a better interface to HandToHand.
  47.  
  48. #pragma parameter __A0 CopyHandle(__A0)
  49. pascal void *CopyHandle(void *) = {0xA9E1};
  50.  
  51. // jbGetHandleSize is just GetHandleSize, without the error checks.
  52.  
  53. #pragma parameter __D0 jbGetHandleSize(__A0)
  54. pascal Size jbGetHandleSize(void *h) = 0xA025;
  55.  
  56. // QuickMove is faster than BlockMove for very small moves and won't flush the cache.
  57. // However, it always moves at least one byte!
  58.  
  59. #pragma parameter QuickMove(__A0, __A1, __D0)
  60. pascal void QuickMove(void *from, void *to, short bytes) = {0x12D8, 0x5340, 0x62FA};
  61.  
  62. // MakeALong makes a long out of two shorts efficiently.
  63.  
  64. #pragma parameter __D0 MakeALong(__D0, __D1)
  65. pascal long MakeALong(short HiWord, short LoWord) = {0x4840, 0x3001};
  66.  
  67. // MinShort takes the minimum of two input shorts efficiently
  68.  
  69. #pragma parameter __D0 MinShort(__D0, __D1)
  70. pascal short MinShort (short a, short b) = {0xB240, 0x6E02, 0x3001};
  71.  
  72. // MaxShort takes the maximum of two input shorts efficiently
  73.  
  74. #pragma parameter __D0 MaxShort(__D0, __D1)
  75. pascal short MaxShort (short a, short b) = {0xB240, 0x6D02, 0x3001};
  76.  
  77. // jbLoWord quickly retrieves the low word of a long..
  78.  
  79. #define jbLoWord(l) ((short)(l))
  80.  
  81. // jbHiWord quickly retrieves the high word of a long..
  82.  
  83. #pragma parameter __D0 jbHiWord(__D0)
  84. pascal short jbHiWord(long Long) = {0x4840};
  85.  
  86. // jbDelay is a better interface for Delay.
  87.  
  88. #pragma parameter __A0 jbDelay(__A0)
  89. pascal long jbDelay(long numTicks)
  90.     = {0xA03B}; 
  91.  
  92. // PenWhite calls PenPat(white) from QuickDraw's globals.
  93.  
  94. pascal void PenWhite(void)
  95.     =    {0x2055, 0x4868, 0xFFF8, 0xA89D};
  96.  
  97. // PenBlack calls PenPat(black) from QuickDraw's globals.
  98.  
  99. pascal void PenBlack(void)
  100.     =    {0x2055, 0x4868, 0xFFF0, 0xA89D};
  101.  
  102. // PenGray calls PenPat(gray) from QuickDraw's globals.
  103.  
  104. pascal void PenGray(void)
  105.     =    {0x2055, 0x4868, 0xFFE8, 0xA89D};
  106.  
  107. // ArrowCursor calls SetCursor(arrow) from QuickDraw's globals.
  108.  
  109. pascal void ArrowCursor(void)
  110.     =    {0x2055, 0x4868, 0xFF94, 0xA851};
  111.  
  112. // PStringMove is a quick pascal string copy using the toolbox.
  113.  
  114. #pragma parameter PStringMove(__A0,__A1)
  115. pascal void PStringMove(const void *srcPtr,void *destPtr)
  116.     = {0x7001, 0xD010, 0xA02E}; 
  117.  
  118. // QStringMove is a quick inline pascal string copy.  By not
  119. // calling BlockMove it's faster and doesn't flush the cache.
  120.  
  121. #pragma parameter QStringMove(__A0,__A1)
  122. pascal void QStringMove(const void *srcPtr,void *destPtr)
  123.     = {0x7000, 0x1010, 0x12D8, 0x51C8, 0xFFFC};
  124.  
  125. // a quicker inline for access to NumToString when you need it:
  126.  
  127. #pragma parameter iNumToString(__D0, __A0)
  128. pascal void iNumToString(long theNum, void *theString) = {0x4267, 0xA9EE};
  129.  
  130. // a quicker inline for access to StringToNum when you need it:
  131.  
  132. #pragma parameter __D0 iStringToNum(__A0)
  133. pascal long iStringToNum(void *theString) = {0x3F3C, 0x0001, 0xA9EE};
  134.  
  135. // Why HOpenResFile isn't declared this way, I don't know.
  136. // (Under System 7, HORF has its own trap)
  137.  
  138. pascal short HOpenResFile7(short vRefNum,long dirID,ConstStr255Param fileName,
  139.     char permission) = 0xA81A;
  140.  
  141. // jbRelString is an interface to the RelString trap.  It returns a result such
  142. // that "jbRelString(s1, s2) > 0" returns the same as "s1 > s2", that is, zero
  143. // if the strings are equal, 1 if s1 is greater that s2, -1 if neither.
  144.  
  145. extern short jbRelString(void *first, void *second);